<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>非受控组件</title>
    </head>
    <body>
        <div id="root"></div>

        <script src="../js/react.development.js"></script>
        <script src="../js/react-dom.development.js"></script>
        <script src="../js/babel.min.js"></script>

        <script type="text/babel">
            class App extends React.Component {
                render() {
                    return (
                        <div>
                            <h2>登录</h2>
                            <form action="" onSubmit={this.submit}>
                                用户名: <input type="text" ref={el => this.user = el} />
                                <br />
                                密码: <input type="text" ref={el => this.pass = el} />
                                <br />
                                <button onClick={this.login}>登录</button>
                            </form>
                        </div>
                    );
                }

                login = (e) => {
                    //获取用户名和密码的值
                    let username = this.user.value;
                    let password = this.pass.value;
                    //输出
                    console.log(`用户名为: ${username}  密码为: ${password}`)
                }

                submit = (e) => {
                    e.preventDefault();
                }
            }

            ReactDOM.render(<App />, document.querySelector("#root"));
        </script>
    </body>
</html>
